<template>
	<view class="wrap">
		<u-form class="form" :model="model" :rules="rules" ref="uForm" label-position="left">
			<u-calendar v-model="show" mode="date" @change="change" max-date="2099-12-31"></u-calendar>
			<u-form-item label="提交人" prop="leaveTime" label-width="180" v-if="model.leaveId">
				<u-input v-model="model.username" type="text" disabled="true" @click="show = true"></u-input>
			</u-form-item>
			<u-form-item label="开始时间" prop="leaveTime" label-width="180">
				<u-input v-model="model.leaveTime" type="text" disabled="true" @click="show = true"></u-input>
			</u-form-item>
			<u-form-item label="天数" prop="days" label-width="180">
				<u-input v-model="model.days" type="number"></u-input>
			</u-form-item>
			<u-form-item label="提交人备注" prop="content" label-width="180">
				<u-input v-model="model.content" type="textarea"></u-input>
			</u-form-item>
			<u-form-item label="审批人批注" prop="content" label-width="180">
				<u-input v-model="model.comment" type="textarea"></u-input>
			</u-form-item>
			<u-image width="100%" height="300rpx" mode="aspectFit" :src="viewSrc">
			</u-image>
		</u-form>
		<view class="form-footer" v-for="(item, index) in model.flagList" :key="index" :index="index">
			<u-button class="btn" type="primary" @click="doTask(item)">{{ item }}</u-button>
		</view>
	</view>
</template>
<script>
import adaptationUrl from "@/utils/baseUrlUtil";
import store from '@/store';

export default {
	data() {
		return {
			show: false,
			isAdd: false,
			viewSrc: '',
			model: {
				leaveId: '',
				days: 1,
				content: '',
				leaveTime: '',
			}
		};
	},
	onLoad(params) {
		let url = `/act/task/view/${params.taskId}?access_token=${store.state.vuexToken.access_token}`;
		this.viewSrc = this.vuexConfig.baseUrl + adaptationUrl(url)
		this.$u.api.unixOA.getTask(params).then(res => {
			Object.assign(this.model, res.data);
		});
	},
	onReady() {

	},
	methods: {
		doTask(flag) {
			this.$u.api.unixOA.doTask(this.model).then(res => {
				uni.showModal({
					title: '提示',
					content: flag + '成功',
					showCancel: false,
					success: function () {
						uni.navigateTo({
							url: '/pages/oa/todos'
						})
					}
				});
			});
		}
	}
};
</script>
<style lang="scss"></style>
